<?php
  require(dirname(__FILE__).'/global.php');
  require(ROOT.'/admin/isLogin.php');
  require(ROOT.'/include/xml.class.php');
  require(ROOT.'/include/data.class.php');
  
  $submit = $_POST['submit'];
  $xmlPath = ROOT.'/common.xml';
  if(!isset($submit)){              
      $xml = new SimpleXMLUtil($xmlPath);
      $picAttachSize = $xml->getElementValue('PicAttachSize');
      $fileAttachSize = $xml->getElementValue('FileAttachSize');
      $smarty->assign('pic',$picAttachSize);
      $smarty->assign('file',$fileAttachSize);
      $smarty->display('attach_size.html');
  }
  else{               
      $pic = $_POST['pic'];
      $file = $_POST['file'];
      
      $xml = new SimpleXMLUtil($xmlPath);
      $xml->setElementValue('PicAttachSize',$pic);
      $xml->setElementValue('FileAttachSize',$file);
      $xml->save();
      
      echo json_encode('更新成功');
  }
?>
